Example Presentation

Overview

This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:

datatable(eth_data, rownames = FALSE, 
          options(list(lengthMenu = c(4, 5, 6))))

Price Chart

Interactive Chart

Python Code Example

import pandas as pd
# Create the Python object from R
df = r.cryptodata
# Show the new Python dataframe
df
##         pair symbol  ask_1_price       date_time_utc
## 0     BTCUSD    BTC    18037.560 2020-12-12 00:00:00
## 1     ETHUSD    ETH      544.422 2020-12-12 00:00:01
## 2     BTCUSD    BTC    18338.710 2020-12-12 01:00:00
## 3     ETHUSD    ETH      555.184 2020-12-12 01:00:01
## 4     BTCUSD    BTC    18283.790 2020-12-12 02:00:00
## ...      ...    ...          ...                 ...
## 5075  BTCUSD    BTC    11847.080 2020-08-10 21:03:49
## 5076  BTCUSD    BTC    11819.920 2020-08-10 22:03:49
## 5077  BTCUSD    BTC    11804.900 2020-08-10 23:03:54
## 5078  BTCUSD    BTC    10686.880                 NaT
## 5079  ETHUSD    ETH      357.844                 NaT
## 
## [5080 rows x 4 columns]

One more Python example

Press on w on your keyboard to make the presentation wider. Press f to fullscreen.

import numpy as np
# Create a new field based on the ask_1_price value:
df['price_percentile'] = np.where(df['ask_1_price'] > np.percentile(df['ask_1_price'], 50),
                            'upper 50th percentile of prices', 
                            'lower 50th percentile of prices')
# Show modified dataframe:
df[['symbol', 'ask_1_price', 'price_percentile']]
##      symbol  ask_1_price                 price_percentile
## 0       BTC    18037.560  upper 50th percentile of prices
## 1       ETH      544.422  lower 50th percentile of prices
## 2       BTC    18338.710  upper 50th percentile of prices
## 3       ETH      555.184  lower 50th percentile of prices
## 4       BTC    18283.790  upper 50th percentile of prices
## ...     ...          ...                              ...
## 5075    BTC    11847.080  upper 50th percentile of prices
## 5076    BTC    11819.920  upper 50th percentile of prices
## 5077    BTC    11804.900  upper 50th percentile of prices
## 5078    BTC    10686.880  upper 50th percentile of prices
## 5079    ETH      357.844  lower 50th percentile of prices
## 
## [5080 rows x 3 columns]